﻿using HKB.Web.Admin;
using System;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class Admin_Admin_attachment : Admin, IRequiresSessionState
{
    public string ImageURL
    {
        get;
        set;
    }
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.IsPostBack)
        {
            if (!base.admin.CheckAdminPower(13))
            {
                this.ButUpLoadimage.Enabled = false;
            }
        }
    }
    protected void ButUpLoadimage_Click(object sender, EventArgs e)
    {
        string str = "";
        try
        {
            string fileName = this.uploadPhoto.FileName;
            string text = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower();
            string contentType = this.uploadPhoto.PostedFile.ContentType;
            Random random = new Random();
            string str2 = (10 + random.Next(99)).ToString();
            string str3 = DateTime.Now.ToString("yyyyMMddHHmmss") + str2;
            string text2 = str3 + "." + text;
            if (text == "jpg" || text == "gif" || text == "png" || text == "bmp" || text == "jpeg")
            {
                string filename = base.Server.MapPath("..") + "\\AD\\UploadAdPic\\" + text2;
                this.uploadPhoto.PostedFile.SaveAs(filename);
                str = "/AD/UploadAdpic/" + text2;
            }
            else
            {
                base.Response.Write("上传图片格式不正确，请<a href='Admin_attachment.aspx'>重新上传</a>！");
                this.upload_photo_panel.Visible = false;
                str = "";
            }
        }
        catch
        {
        }
        this.imgPreview.ImageUrl = base.Request.Url.ToString().Remove(base.Request.Url.ToString().IndexOf(base.Request.Url.AbsolutePath)) + str;
        base.Response.Write("<script type=\"text/javascript\">self.parent.callBack('" + str + "');</script>");
    }
}
